const origin = window.location.origin;

const awen = "http://crm.angwen.vip";
const ayun = "http://crm.vipcc.cn";
const qbxy = "http://crm.qingbeijy.com";

const isQbxy = origin === qbxy || process.env.NODE_ENV !== "production";
const isProd = process.env.NODE_ENV === "production";
const devRedirectUrl = encodeURIComponent("http://localhost:8080/#/login");

const config = {
  isQbxy: origin === qbxy,
  isAWen: origin === awen,
  isAYun: origin === ayun,
  title: "",
  corpId: "",
  dingAppid: "",
  dingRedirectUrl: "",
};

if (isQbxy) {
  config.title = "轻备";
  config.corpId = "dinge30e4d4df3d7733e35c2f4657eb6378f";
  if (isProd) {
    config.dingAppid = "dingoa6n20hrwd4ps4rwum";
    config.dingRedirectUrl = encodeURIComponent(`${qbxy} /#/loginLoading`);
  } else {
    config.dingAppid = "dingoa2lkf9pdtj82naidd";
    config.dingRedirectUrl = devRedirectUrl;
  }
}

if (origin === awen) {
  config.title = "昂文";
  config.corpId = "ding8dda1856885125d735c2f4657eb6378f";
  if (isProd) {
    config.dingAppid = "dingoac9cx0uxbcyekcyjo";
    config.dingRedirectUrl = encodeURIComponent(` ${awen}/#/loginLoading`);
  } else {
    config.dingAppid = "dingoatco7nrji2xe7utmt";
    config.dingRedirectUrl = devRedirectUrl;
  }
}

if (origin === ayun) {
  config.title = "昂云";
  config.corpId = "ding60fb69072c11a403f5bf40eda33b7ba0";
  if (isProd) {
    config.dingAppid = "dingoau16wgqvv7hg9g6ab";
    config.dingRedirectUrl = encodeURIComponent(`${ayun} /#/loginLoading`);
  }
}

export default config;
